/**
 * Copyright (c) 2020 kedacom
 * OpenATC is licensed under Mulan PSL v2.
 * You can use i18n software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 * http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 **/
import i18n from '../../i18n/index.js'
export default class ServiceUtil {
  // eslint-disable-next-line no-useless-constructor
  constructor () {}

  getContent (row) {
    let res = '--'
    if (!row.data) {
      return res
    }
    let control = row.data.control
    let data = row.data
    if (control === 4) {
      let value = data.value ? data.value : 0
      if (value === 0) {
        res = i18n.t('openatc.dutyroute.nextStage')
      } else {
        res = i18n.t('openatc.dutyroute.stage') + ' ' + value
      }
    } else if (control === 22) {
      res = i18n.t('openatc.greenwaveoptimize.phase')
      let phases = data.data.phases
      if (phases) {
        let phaseIdArr = []
        for (let dir of phases) {
          if (dir.type !== 0) {
            let phaseId = dir.id
            phaseIdArr.push(phaseId)
          }
        }
        res = res + ' ' + phaseIdArr.join('、')
      }
    } else if (control === 23) { // 相位关断
      res = i18n.t('openatc.greenwaveoptimize.phase')
      let phases = data.data.phases
      if (phases) {
        let phaseIdArr = []
        for (let dir of phases) {
          if (dir.close && dir.close !== 0) {
            let phaseId = dir.id
            phaseIdArr.push(phaseId)
          }
        }
        res = res + ' ' + phaseIdArr.join('、')
      }
    } else if (control === 24) { // 优先控制
      let targetData = data
      let value = targetData.phase ? targetData.phase : 0
      let type = targetData.type ? targetData.type : 0
      let phaseMsg = i18n.t('openatc.greenwaveoptimize.phase') + ' ' + value
      let typeMsg = type === 0 ? i18n.t('openatccomponents.overview.typeOption0') : i18n.t('openatccomponents.overview.typeOption1')
      res = typeMsg + ' ' + phaseMsg
    } else if (control === 100) { // 临时方案
      res = i18n.t('openatc.greenwaveoptimize.phase')
      let offset = data.data.offset
      let cycle = data.data.cycle
      res = i18n.t('openatc.greenwaveoptimize.offset') + '：' + offset + ' , ' + i18n.t('openatc.greenwaveoptimize.cycle') + '：' + cycle
    // } else {
    //   res = i18n.t('openatccomponents.overview.modelList' + control) + ' - ' + data.duration + 's'
    }
    return res
  }
}
